<template>
    <div class="container">
        <div class="province">
            <div>省份</div>
            <div>{{ category.name }}</div>
        </div>
        <div class="name">
            <div>餐厅名称</div>
            <div>{{ category.title }}</div>
        </div>
        <div class="comment">
            <div>评论</div>
            <div v-for="item in this.comments" :key="item.id" >{{ item }}</div>
        </div>
    </div>
</template>
<script>
import { get } from '@/utils/request'
export default {

    data() {
        return {
            params: {
                page: 1,
                pageSize: 10000
            },
            // name:sessionStorage.getItem('name'),
            category: {},
            id: '',
            //餐厅数量
            total: 0,
            //评论列表
            comments:[]
        }
    },
    watch: {
        form: {
            handler() {
                this.params.page = 1;
                this.getArticle()
            },
            deep: true
        }

    },
    methods: {
        // async columnArticle() {
        //     //无参：get(url)    有参：传对象{}  axios会自动转为xx字符串
        //     this.category = this.$route.query.category;
        //     console.log(this.category, '123131dasdasd')
        //     this.id = this.$route.query.id;
        // },
        async getArticle() {
            let res = await get('/comment/pageQuery', this.params);
            console.log(res, 'asdoadokaodkao')
            console.log(this.id)
            for (let i = 0; i < res.data.list.length; i++) {
                console.log(i, '遍历list数组');
                if (this.id == res.data.list[i].articleId) {
                    this.comments.push(res.data.list[i].comment)
                }
            }
            console.log(this.comments);
        },

    },
    created() {
        console.log(this.$route.query, '接收传递参数');
        // if(!this.name||this.name=='undefined'||this.name!=this.$route.query.category.name){
        //     sessionStorage.setItem('name',this.$route.query.category.name)
        // }
        this.category = this.$route.query;
        this.id = this.$route.query.id;
        this.getArticle()
    }
}
</script>
<style lang="scss" scoped>
.container>div{
    margin-top:50px ;
}

</style>